package com.holly.unit.bpmn.designer.enums;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 类描述: 流程节点类型 枚举
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/7 8:35
 */
public enum NodeTypeEnum {

    // 审批人节点
    SP("approver"),
    // 抄送人节点
    CS("copy"),
    // 条件节点
    TJ("TJ"),
    // 根节点
    ROOT("ROOT"),
    // 空节点
    EMPTY("empty"),
    // 条件
    CONDITION("CONDITION");

    String fieldName;

    NodeTypeEnum(String fieldName) {
        this.fieldName = fieldName;
    }

    public String fieldName() {
        return this.fieldName;
    }

    public static NodeTypeEnum of(String fieldName) {
        return Stream.of(NodeTypeEnum.values())
                .filter(clazz -> Objects.equals(clazz.fieldName(), fieldName))
                .findFirst()
                .orElse(SP);
    }

}
